//
//  WaterShopCell.m
//  瀑布流1
//
//  Created by yuanyuan on 15-3-9.
//  Copyright (c) 2015年 hanjiaxue. All rights reserved.
//

#import "WaterShopCell.h"
#import "WaterFallScrollView.h"
#import "WaterShop.h"
#import "UIImageView+WebCache.h"

@interface WaterShopCell ()
@property(nonatomic,strong)UIImageView *imageView;
@property(nonatomic,strong)UILabel *priceLabel;
@end

@implementation WaterShopCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *imageView=[[UIImageView alloc]init];
        [self addSubview:imageView];
        self.imageView=imageView;
        
//        UILabel *priceLabel=[[UILabel alloc]init];
//        priceLabel.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
//        priceLabel.textAlignment=NSTextAlignmentCenter;
//        priceLabel.textColor=[UIColor whiteColor];
//        [self addSubview:priceLabel];
//        self.priceLabel=priceLabel;
        
    }
    return self;
}

+(instancetype)cellWithwaterflowView:(WaterFallScrollView *)waterflowView
{
    static NSString *ID=@"ID";
    WaterShopCell *cell=[waterflowView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell=[[WaterShopCell alloc]init];
        cell.identifier=ID;
    }
    return cell;
}

-(void)setShop:(WaterShop *)shop
{
    _shop=shop;
    self.priceLabel.text=shop.price;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:shop.img] placeholderImage:[UIImage imageNamed:@"loading"]];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.frame=self.bounds;
    
    CGFloat priceX=0;
    CGFloat priceH=25;
    CGFloat priceY=self.bounds.size.height-priceH;
    CGFloat priceW=self.bounds.size.width;
    
    self.priceLabel.frame=CGRectMake(priceX, priceY, priceW, priceH);
}






@end
